#include "Ctrl.h"

#if CommandPattern_


class Receiver
{
public:
	void Action() {
		cout << "执行请求！" << endl;
	}
};


class Command
{
protected:
	Receiver* m_pReceiver;
public:
	Command(Receiver* _receiver) {
		m_pReceiver = _receiver;
	}
	virtual void Execute() = 0;
};

class ConcreteCommand : public Command
{
public:
	ConcreteCommand(Receiver* _pReceiver) : Command(_pReceiver){}
	void Execute() override{
		m_pReceiver->Action();
	}
};

class Invoker
{
private:
	Command* m_pCommand;
public:
	void SetCommand(Command* _pCommand) {
		m_pCommand = _pCommand;
	}
	void ExecuteCommand() {
		m_pCommand->Execute();
	}
};



int main() {
	Receiver* pR = new Receiver();
	Command* pC = new ConcreteCommand(pR);
	Invoker* pI = new Invoker();
	pI->SetCommand(pC);
	pI->ExecuteCommand();
}




#endif